package com.dody.agile.payment.schedule;


import com.dody.agile.payment.utils.DateUtils;

import java.util.Calendar;
import java.util.Date;

/**
 * @author ShiXin
 * @date 2019/4/11 19:44
 * @description agile
 */
public class WeeklySchedule implements PaymentSchedule {
    @Override
    public boolean isPayDay(Date date) {
        return DateUtils.isFriday(date);
    }

    @Override
    public Date getPayPeriodStartDate(Date payPeriodEndDate) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(payPeriodEndDate);
        calendar.add(Calendar.DAY_OF_MONTH,-7);
        return calendar.getTime();
    }

    public static void main(String[] args) {
        WeeklySchedule weeklySchedule = new WeeklySchedule();
        Calendar calendar = Calendar.getInstance();
        calendar.set(2019,Calendar.APRIL,16);
        Date date = weeklySchedule.getPayPeriodStartDate(calendar.getTime());
        System.out.println(date);
    }
}
